package com.sonicvision.resourcetracker.employee;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.springframework.stereotype.Repository;

import com.sonicvision.resourcetracker.exceptions.DAOException;

@Repository
public class EmployeeDocumentsJPAImpl implements EmployeeDocumentsDAO {
	
	@PersistenceContext(unitName="resourcetracker")
	private EntityManager em;

	
	@Override
	public void addEmpDoc(EmployeeDocuments employeeDoc) throws DAOException {
		            em.persist(employeeDoc);
		
	}

	@Override
	public void updateEmpDoc(EmployeeDocuments document_Id) throws DAOException {
		    
		   if (document_Id == null){			
			throw new DAOException ("Employee Document not found");			
		   } else {			   
			em.merge(document_Id);
		}
		
	}

	@Override
	public void deleteEmpDoc(EmployeeDocuments document_Id) throws DAOException {
		        
		if (document_Id == null){			
			throw new DAOException ("Employee Document not found");			
		   } else {			   
			em.remove(document_Id);
		}
		
	} 

	
}
